<?php
class Fineart extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('fineart');
        $this->hasColumn('texto1', 'string', 10000);
        $this->hasColumn('texto2', 'string', 10000);
        $this->hasColumn('texto3', 'string', 10000);
    }
    
    public function setUp(){
        $this->hasMany('Imagen as imagenes', array(
            'local' => 'id',
            'foreign' => 'id_fineart'
        ));
    }    
    
    //GETTERS Y SETTERS
    public static function getInstance () {
        return Doctrine::getTable('fineart')->find(1);
    }
    
    public function getTexto1 () {
        return utf8_decode($this->_get('texto1'));
    }
    public function setTexto1 ($q) {
        $this->_set('texto1', utf8_encode($q));
    }
    
    public function getTexto2 () {
        return utf8_decode($this->_get('texto2'));
    }
    public function setTexto2 ($q) {
        $this->_set('texto2', utf8_encode($q));
    }
    
    public function getTexto3 () {
        return utf8_decode($this->_get('texto3'));
    }
    public function setTexto3 ($q) {
        $this->_set('texto3', utf8_encode($q));
    }
    
    public function imagenes () {
        $q = Doctrine_Query::create()
            ->select('i.*')
            ->from('Imagen i')
            ->innerJoin('i.fineart a')
            ->where('a.id = '.$this->id)
            ->orderBy('i.orden');
        return $q->execute();
    }
    //FIN GETTERS Y SETTERS
}
?>